package com.robot.thread;

import com.robot.dto.RunTestContext;
import com.robot.model.BuildTestDo;
import com.robot.service.MailReportService;
import com.robot.service.RunTestService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created with IntelliJ IDEA.
 * User: li
 * Date: 2019/12/8
 * Time: 10:07
 * PROJECT：robot
 * PACKAGE: com.robot
 *
 * @author:55324936@qq.com To change this template use File | Settings | File Templates.
 */
public class ThreadRunTest implements Runnable {

    private Integer buildTestId;

    RunTestService runTestService;

    MailReportService mailReportService;

    public ThreadRunTest(Integer buildTestId,RunTestService runTestService){
        this.buildTestId =buildTestId;
        this.runTestService=runTestService;
    }
    public ThreadRunTest(Integer buildTestId, RunTestService runTestService, MailReportService mailReportService){
        this.buildTestId =buildTestId;
        this.runTestService=runTestService;
        this.mailReportService=mailReportService;
    }

    @Override
    public void run() {
        /**这里是真正执行的内容**/
        RunTestContext runTestContext=new RunTestContext();
        BuildTestDo buildTestDo=new BuildTestDo();
        buildTestDo.setId(buildTestId);
        runTestContext.setBuildTestDo(buildTestDo);
        runTestService.runTest(runTestContext);
        /**
         * 测试完成之后去发送测试报告
         * **/
        if(null!=mailReportService){
            mailReportService.sendMail(runTestContext);
        }
    }
}
